﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.Bliss.Services;

public partial class Controls_CreateGroup : UserControlBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ClearMessage();
            IUserService service = new UserService();
            if (service.IsUserInRole(UserID.Value, Utility.Roles.Manager.ToString()))
            {
                maintable.Visible = true;
            }
            else
            {
                maintable.Visible = false;
               ErrorMessage = "You dont have permission to create group.";
            }
        }
    }
    protected void ButtonCreate_Click(object sender, EventArgs e)
    {
        IUserService service = new UserService();
        try
        {
            service.CreateGroup(UserID.Value, txtGroupName.Text, txtDescription.Text);
            SuccessMessage = "Group created successfully";
            txtGroupName.Text = "";
            txtDescription.Text = "";
        }
        catch (Exception ex)
        {
            ExceptionMessage = ex.Message;
        }
    }
}